using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;


namespace DatabaseMemoryChecker
{
    internal static class NativeMethods
    {

        [DllImport("coredll.dll", SetLastError = true, EntryPoint = "GlobalMemoryStatus")]
        internal extern static IntPtr GlobalMemoryStatus(out MemoryStatus memoryStatus);

        public struct MemoryStatus
        {
            uint dwLength; //we aren't using this
            public int MemoryLoad;
            public int TotalPhys;
            public int AvailPhys;
            public int TotalPageFile;
            public int AvailPageFile;
            public int TotalVirtual;
            public int AvailVirtual;
        }

        public static int AvailVirtual()
        {
            MemoryStatus status;
            GlobalMemoryStatus(out status);
            return status.AvailVirtual;
        }
    }
}
